package com.example.saiweisi.service.impl.sysTemAdminService;

import com.example.saiweisi.controller.request.CaipinRequest;
import com.example.saiweisi.mapper.systemAdminMapper.CaipinMapper;
import com.example.saiweisi.model.Caipin;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CaipinService{
    @Autowired
    CaipinMapper chefAdminMapper;


    public PageInfo<Caipin> page(CaipinRequest chefAdminRequest) {
        PageHelper.startPage(chefAdminRequest.getPageNum(), chefAdminRequest.getPageSize());
        List<Caipin> userList = chefAdminMapper.page(chefAdminRequest);
        return new PageInfo<>(userList);
    }


    public void add(Caipin chefAdmin) {
        chefAdminMapper.insertSelective(chefAdmin);
    }


    public void delete(Integer chefAdminId) {
        Caipin desk = new Caipin();
        desk.setId(chefAdminId);
        desk.setIsDelete(1);
        chefAdminMapper.updateByPrimaryKeySelective(desk);
    }


    public Caipin getById(Integer chefAdminId) {
        return chefAdminMapper.selectByPrimaryKey(Long.valueOf(chefAdminId));
    }


    public void update(Caipin chefAdmin) {
        chefAdminMapper.updateByPrimaryKeySelective(chefAdmin);
    }


    public void deletes(List<Integer> chefAdminIds) {
        for (Integer a:chefAdminIds
             ) {
            Caipin desk = new Caipin();
            desk.setId(a);
            desk.setIsDelete(1);
            chefAdminMapper.updateByPrimaryKeySelective(desk);
        }
    }
//

}
